<template>
  <div>
    <SideMenu></SideMenu>
      <el-card style="width: 50%;height:500px;margin: 50px auto">
        <h2> 发布作业 </h2>
        <el-form  style="text-align: left" ref="formRef"  :model="form">
          <div style="margin:0;margin-left: 200px">
            <br>
          <el-select v-model="value" placeholder="请选择" >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
          </el-select>
          </div>
          <br>
        <el-form-item label="作业名称" :label-width="formLabelWidth" prop="homework">
          <el-input v-model="form.homework" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="作业详情" :label-width="formLabelWidth" prop="homeworkinfo">
          <el-input v-model="form.homeworkinfo" autocomplete="off"></el-input>
        </el-form-item>
        <el-button style="margin-left: 220px"  @click="resetForm">重 置</el-button>
        <el-button style="margin-left: 50px" type="primary" @click="onSubmit">确 定</el-button>
      </el-form>
      </el-card>
  </div>
</template>

<script>
    import SideMenu from "./SideMenu";
  export default {
      components: {SideMenu},
    name: 'addLesson',
    data () {
      return {
        options: [{
          value: '选项1',
          label: '黄金糕'
        }, {
          value: '选项2',
          label: '双皮奶'
        }, {
          value: '选项3',
          label: '蚵仔煎'
        }, {
          value: '选项4',
          label: '龙须面'
        }, {
          value: '选项5',
          label: '北京烤鸭'
        }],
        value: '',
        dialogFormVisible: false,
        form: {
            sessionname: '',
            homework: '',
            homeworkinfo: '',
        },
          responseResult: [],
        formLabelWidth: '120px'
      }
    },
    methods: {
        resetForm() {
            console.log(this)
            this.$refs.formRef.resetFields()
        },
      onSubmit () {
        this.$axios
          .post('/addhomework', {
              sessionname: this.form.sessionname,
              homework: this.form.homework,
              homeworkinfo: this.form.homeworkinfo
          }).then(resp => {
          if (resp && resp.status === 200) {
            this.dialogFormVisible = false
              this.$message.success('添加成功');
          }
            else if (successResponse.data.code === 400){
                this.$message.error('添加失败');
            }
        })
      }
    }
  }
</script>

<style scoped>
  .el-icon-circle-plus-outline {
    margin: 50px 0 0 20px;
    font-size: 100px;
    float: left;
    cursor: pointer;
  }
</style>
